﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Articles.master" AutoEventWireup="false" CodeFile="SearchArticles.aspx.vb" Inherits="SearchArticles" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<fieldset>
<legend>Search Criteria</legend>
<ul>
<li><asp:Label ID="lblSearch" runat="server" Text="Enter Text"></asp:Label></li>
<li><asp:TextBox ID="txtSearch" runat="server"></asp:TextBox></li>
<li>
    <asp:Button ID="btnSearch" runat="server" Text="Search" /></li>
</ul>
</fieldset>
<fieldset>
<legend>Search Results</legend>
    <asp:ScriptManager ID="SManSearch" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress runat="server" ID="UProSearch" DisplayAfter="1000">
    <ProgressTemplate>
        <img src="pix/ajax-loader.gif" alt="Please Wait..."/>
    </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UPSearch" runat="server">
   <Triggers>
   <asp:AsyncPostBackTrigger ControlID="btnSearch" />
   </Triggers>
  <ContentTemplate>
    <asp:GridView ID="DGSearchArticles" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="DSSearch">
        <Columns>
            <asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="DateSubmitted" HeaderText="DateSubmitted" 
                SortExpression="DateSubmitted" />
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="ArticleDetails.aspx?ID={0}" HeaderText="Details" 
                Text="More..." />
        </Columns>
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>


    <br />
    <br />
    <asp:SqlDataSource ID="DSSearch" runat="server" 
        ConnectionString="<%$ ConnectionStrings:myFirstDatabase %>" 
        ProviderName="<%$ ConnectionStrings:myFirstDatabase.ProviderName %>" 
        
        SelectCommand="SELECT DISTINCT [Topic], [Title], [ID], [DateSubmitted] FROM [QArticleDetails] WHERE ([Content] LIKE '%' + ? + '%')">
        <SelectParameters>
            <asp:ControlParameter ControlID="txtSearch" Name="Content" PropertyName="Text" 
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</fieldset>
</asp:Content>

